package org.curiouscreature.android.shelves.activity;
import java.util.Date;

import org.curiouscreature.android.shelves.R;
import org.curiouscreature.android.shelves.util.CookieStore;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Toast;

public class WelcomePage extends Activity {
	private long startTime = 0;
	private static final int  SHORT_TIME = 0;
	private Handler mHandler = new Handler(){
		public void handleMessage (Message msg){
			if(msg.what == SHORT_TIME){
				showMainPage();
			}
			
		}
	};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.wel_come_page); 
		setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
		startTime = new Date().getTime();
		
	}

	protected void onStart() {
		super.onStart();

	}

	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		mHandler.sendEmptyMessageDelayed(SHORT_TIME, 3000);
	}

	protected void onPause(){
		super.onPause();
		mHandler.removeMessages(SHORT_TIME);
		
	}
	private void showMainPage() {
		CookieStore.initialize(this);
		Intent intent = new Intent(WelcomePage.this, ShelvesActivity.class);
		startActivity(intent);
		finish();
	}

	public boolean onTouchEvent(MotionEvent event) {
		
		switch (event.getAction()){  
			case MotionEvent.ACTION_DOWN:  
				//Toast.makeText(this, "启动：", 1).show();
				//showMainPage();
				break;  
			case MotionEvent.ACTION_MOVE:  
				//showMainPage();
				break;  
			case MotionEvent.ACTION_UP:  
				showMainPage();
				break;  
		}  
		return true;  
		
		 
	 }
}
